package com.lxy.mychat1.Adapter;

import android.content.Context;
import android.text.Layout;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ArrayAdapter;
import android.widget.ImageView;
import android.widget.TextView;

import androidx.annotation.NonNull;

import com.lxy.mychat1.Bean.PyqItem;
import com.lxy.mychat1.R;

import java.util.IllegalFormatCodePointException;
import java.util.List;

public class PyqItemAdapter extends ArrayAdapter<PyqItem> {
    int resourceid;

    public PyqItemAdapter(@NonNull Context context, int resource, @NonNull List<PyqItem> objects) {
        super(context, resource,objects);
        this.resourceid=resource;
    }
    @Override
    public View getView(int position, View converView, ViewGroup parent){
        View view=converView;
        if (view==null){
            view= LayoutInflater.from(getContext()).inflate(resourceid,null);

        }
        ImageView userimg=view.findViewById(R.id.userimg);
        TextView  username=view.findViewById(R.id.username);
        TextView  usercontent=view.findViewById(R.id.usercontent);
        ImageView contentimg=view.findViewById(R.id.contactimg);
        PyqItem p=getItem(position);
        userimg.setImageResource(p.getUserimg());
        username.setText(p.getUsername());
        usercontent.setText(p.getPyqcontent());
        contentimg.setImageResource(p.getPyqimg());
        return view;

    }
}
